/*
 * Copyright(C) 2009, kesalin All rights reserved.
 * 
 * File name : UException.h
 * Brief     : Excetpion class.
 * Version   : 1.0
 * Author    : kesalin@gmail.com
 * Date      : 2009-6-5
 */

#pragma once

#include "UCommon.h"

namespace LuoUtils {

// Exception
class Exception {

public:

	virtual ~Exception() = 0;

}; // Exception

// LogicalError
class LogicalError : public Exception {

	CStringW m_Message;

public:

	LogicalError(LPCWSTR msg) :
		m_Message(msg)
	{
	}

	virtual ~LogicalError()
	{
	}

	LPCWSTR GetMessage() const
	{
		return m_Message;
	}

	static void DECL_NORETURN Throw(LPCWSTR msg)
	{
	}

}; // LogicalError

// RuntimeError
class RuntimeError : public Exception {

public:

	virtual ~RuntimeError() = 0;

}; // RuntimeError

// WinError
class WinError : public RuntimeError {

	HRESULT  m_Result;
	CStringW m_Message;

public:

	WinError(HRESULT hRslt, LPCWSTR msg) :
		m_Result (hRslt),
		m_Message(msg)
	{
	}

	virtual ~WinError()
	{
	}

	HRESULT GetResult() const
	{
		return m_Result;
	}

	LPCWSTR GetMessage() const
	{
		return m_Message;
	}

	static void DECL_NORETURN Throw(HRESULT hRslt, LPCWSTR msg)
	{
	}
	static void DECL_NORETURN ThrowLastError(LPCWSTR msg)
	{
	}

}; // WinError

// SocketError
class SocketError : public RuntimeError {

	int      m_Code;
	CStringW m_Message;

public:

	SocketError(int code, LPCWSTR msg) :
		m_Code   (code),
		m_Message(msg)
	{
	}

	virtual ~SocketError()
	{
	}

	int GetCode() const
	{
		return m_Code;
	}

	LPCWSTR GetMessage() const
	{
		return m_Message;
	}

	static void DECL_NORETURN Throw(LPCWSTR msg)
	{
	}
	static void DECL_NORETURN Throw(LPCWSTR msg, int code)
	{
	}

}; // SocketError

// CRTError
class CRTError : public RuntimeError {

	int      m_Code;
	CStringW m_Message;

public:

	CRTError(int code, LPCWSTR msg) :
		m_Code   (code),
		m_Message(msg)
	{
	}

	virtual ~CRTError()
	{
	}

	int GetCode() const
	{
		return m_Code;
	}

	LPCWSTR GetMessage() const
	{
		return m_Message;
	}

	static void DECL_NORETURN Throw(LPCWSTR msg)
	{
	}
	static void DECL_NORETURN Throw(LPCWSTR msg, int code)
	{
	}

}; // CRTError

} // namespace LuoUtils

